# Generated by Django 4.2.4 on 2023-11-15 12:42

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=50, null=True, verbose_name='имя')),
                ('email', models.EmailField(max_length=254, unique=True, verbose_name='почта')),
                ('comment', models.TextField(blank=True, null=True, verbose_name='Комментарий')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Владелец')),
            ],
            options={
                'verbose_name': 'Клиент',
                'verbose_name_plural': 'Клиенты',
            },
        ),
        migrations.CreateModel(
            name='Message',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('head', models.CharField(max_length=100, verbose_name='Тема')),
                ('body', models.TextField(verbose_name='Сообщение')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')),
            ],
            options={
                'verbose_name': 'Сообщение',
                'verbose_name_plural': 'Сообщения',
            },
        ),
        migrations.CreateModel(
            name='Mailing',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('time_start', models.TimeField(default=django.utils.timezone.now, verbose_name='Время запуска рассылки')),
                ('time_end', models.TimeField(default=django.utils.timezone.now, verbose_name='Время окончания рассылки')),
                ('periodicity', models.CharField(choices=[('DAILY', 'Каждый день'), ('WEEKLY', 'Каждую неделю'), ('MONTHLY', 'Каждый месяц')], max_length=50, verbose_name='Периодичность')),
                ('is_active', models.BooleanField(default=False, max_length=20, verbose_name='Пуск рассылки')),
                ('client', models.ManyToManyField(to='mailing.client', verbose_name='Кому')),
                ('message', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mailing.message', verbose_name='Сообщение')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')),
            ],
            options={
                'verbose_name': 'Настройка',
                'verbose_name_plural': 'Настройки',
            },
        ),
        migrations.CreateModel(
            name='Logs',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('last_try', models.DateTimeField(auto_now_add=True, verbose_name='Время последней попытки')),
                ('status_try', models.CharField(choices=[('OK', 'Успешно'), ('FAILED', 'Ошибка')], default='Успешно', max_length=50, verbose_name='Статус попытки')),
                ('answer', models.CharField(blank=True, max_length=250, null=True, verbose_name='Ответ сервера')),
                ('client', models.EmailField(blank=True, max_length=150, null=True, verbose_name='Email клиента')),
                ('mailing', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mailing.mailing', verbose_name='Рассылка')),
            ],
            options={
                'verbose_name': 'Лог',
                'verbose_name_plural': 'Логи',
            },
        ),
    ]
